const { footer, $ } = require("../../utils/dom");
require("../../assets/css/index.less");
require("./circle.less");
require("../../utils/dom");
const axios = require("axios");
require('../../utils/https');
axios.defaults.headers.common['Authorization'] = "Bearer " + JSON.parse(localStorage.getItem("token"));



async function fn() {
    const res = await axios.get("/api/train/courseList");
    // console.log(res.data.data[0]);
    if (res.data.errno === 0) {
        $(".head img").src = axios.defaults.baseURL + res.data.data[0].imgurl;
        $(".head .text h3").innerHTML = res.data.data[0].name;
        $(".head .text p").innerHTML = res.data.data[0].desc;
    }
}
fn();

async function opinionList() {
    const res = await axios.get("/api/circles/opinionList");
    // console.log(res.data.errno);
    let releaseProvinceId;
    if (res.data.errno === 0) {
        releaseProvinceId = res.data.data.map((v) => {
            // console.log(v);
            return v.releaseProvinceId == 620030 ? v.releaseProvinceId = 620000 : v.releaseProvinceId;
        });
    }
    // console.log(releaseProvinceId);
    const province = await axios.get("/api/shared/province");
    // console.log(province.data.data);
    if (province.data.errno === 0) {
        console.log(province.data);
        const ProvinceId = releaseProvinceId.filter((r) => {
            // console.log(r);
            const arr = province.data.data.filter((v, i) => {
                // console.log(v);
                if (v.id == r) {
                    console.log(r);
                    let html = "";
                    html += `
                        <div class="df data">
                            <img src="../../assets/imgs/dog.jpg">
                            <div>
                                <h4>用户名</h4>
                                <p>
                                    <span id="province"></span>
                                    <span id="city"></span>
                                </p>
                            </div>
                        </div>
                        <p class="text"></p>
                        <div class="img_box">
                            <img src="../../assets/imgs/dog.jpg" data-id="${r}">
                        </div>
                        `
                    $("section").innerHTML = html;
                }
            });
            // console.log(arr[0].name);
            return arr
        });

    };

    // const city = await axios.get("/api/shared/city", {
    //     "params": {
    //         provinceId: ProvinceId
    //     },
    // });
    // console.log(city);
    // if (city.data.errno === 0) {
    //     let arr = city.data.data.filter((v, i) => {
    //         // console.log(v.id);
    //         console.log(r);
    //         if (v.id == r) {
    //             return v.name;
    //         }
    //     });
    //     // console.log(arr);
    // }



}
// opinionList();

footer("circle");